from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Base():
    def __init__(self):
        cop={"platformName": "Android",
  "appium:deviceName": "emulator-5554",
  "appium:automationName": "uiautomator2",
  "appium:appPackage": "com.xiachufang",
  "appium:appActivity": ".activity.home.HomeActivity",
  "appium:noReset": True}
        self.drivce=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cop)
        self.drivce.implicitly_wait(15)
    def find_ele(self,loc):
        ele=self.drivce.find_element(*loc)
        return ele
    def find_ele_w(self,loc):
        ele=WebDriverWait(self.drivce,15).until(EC.element_to_be_clickable(loc))
        return ele
    def tc(self):
        self.drivce.quit()
    def jp(self,a):
        self.drivce.save_screenshot(a)
    def hd(self,q,w,e,r):
        self.drivce.swipe(q,w,e,r,100)
    def qq(self,x,y):
        self.drivce.tap([(x,y)],100)
